﻿// Ŭnicode please
#include "StdAfx.h"
#include "test.h"
#include "SRLight.h"

using namespace sora;

TEST(Light, Ambient)
{
	color4 color(0.1f, 0.2f, 0.3f, 0.4f);
	Light ambient = Light::ambient(color);
	EXPECT_TRUE(color == ambient.color());
	EXPECT_EQ(LightTypeAmbient, ambient.type());
}
TEST(Light, Diffuse)
{
	color4 color(0.1f, 0.2f, 0.3f, 0.4f);
	matsu::vec3 pos(1, 2, 3);
	Light diffuse = Light::diffuse(color, pos);
	EXPECT_TRUE(color == diffuse.color());
	EXPECT_EQ(pos.x, diffuse.pos().x);
	EXPECT_EQ(pos.y, diffuse.pos().y);
	EXPECT_EQ(pos.z, diffuse.pos().z);
	EXPECT_EQ(LightTypeDiffuse, diffuse.type());
}
TEST(LightCodeStack, delim)
{
	const int maxLight = LightCodeStack::MaxLight;
	LightCodeStack stack;
	EXPECT_EQ(maxLight, stack.numRemain());

	//2개 꺼내고 delim넣기
	for(int i = 0 ; i < 2 ; i++)
		stack.pop();
	stack.pushDelim();
	EXPECT_EQ(maxLight-2, stack.numRemain());

	//3개 더 꺼내고 delim넣기
	for(int i = 0 ; i < 3 ; i++)
		stack.pop();
	stack.pushDelim();
	EXPECT_EQ(maxLight-2-3, stack.numRemain());

	//3개 복구
	stack.popDelim();
	EXPECT_EQ(maxLight-2, stack.numRemain());

	//2개 복구
	stack.popDelim();
	EXPECT_EQ(maxLight, stack.numRemain());
}